package com.zeus;

import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * Created by Administrator on 2015/10/17.
 */
public class DateAndTime {

    @Test
    public void getDate(){
        Date date = new Date();
        System.out.println(date);
    }

    @Test
    public void formateDate(){
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yy-MM-dd");
        System.out.println(simpleDateFormat.format(date));

    }

    @Test
    public void useCalendar(){
        Calendar calendar = Calendar.getInstance();
        Date date1 = calendar.getTime();
        System.out.println(date1);
        Calendar cal = new GregorianCalendar(2015,2,12,12,12,12);
        Date date2 = cal.getTime();
        System.out.println((new SimpleDateFormat("yy-MM-dd")).format(date2));
    }
}
